home *** CD-ROM | disk | FTP | other *** search
/ isnet Internet / Isnet Internet CD.iso / prog / hiz / 09 / 09.exe / adynware.exe / perl / lib / site / Win32 / Shortcut.pm < prev    next >
Encoding:
Perl POD Document  |  1999-12-28  |  6.6 KB  |  275 lines

  1. package Win32::Shortcut;
  2.  
  3. require Exporter;       # to export the constants to the main:: space
  4. require DynaLoader;     # to dynuhlode the module.
  5.  
  6. @ISA= qw( Exporter DynaLoader );
  7. @EXPORT = qw(
  8.     SW_SHOWMAXIMIZED
  9.     SW_SHOWMINNOACTIVE
  10.     SW_SHOWNORMAL
  11. );
  12.  
  13.  
  14.  
  15. sub AUTOLOAD {
  16.     my($constname);
  17.     ($constname = $AUTOLOAD) =~ s/.*:://;
  18.     $!=0;
  19.     my $val = constant($constname, @_ ? $_[0] : 0);
  20.     if ($! != 0) {
  21.  
  22.  
  23.     
  24.  
  25.         ($pack, $file, $line) = caller;
  26.         undef $pack; # [dada] and get rid of "used only once" warning...
  27.         die "Win32::Shortcut::$constname is not defined, used at $file line $line.";
  28.  
  29.     }
  30.     eval "sub $AUTOLOAD { $val }";
  31.     goto &$AUTOLOAD;
  32. }
  33.  
  34.  
  35. $VERSION = "0.03";
  36.  
  37.  
  38. sub new {
  39.     my($class, $file) = @_;
  40.     my $self = {}; 
  41.     my $ilink = 0; 
  42.     my $ifile = 0;
  43.  
  44.     ($ilink, $ifile) = _Instance();
  45.  
  46.     if($ilink and $ifile) {
  47.         $self->{'ilink'} = $ilink;
  48.         $self->{'ifile'} = $ifile;
  49.         bless $self;
  50.         $self->{'File'}             = "";
  51.         $self->{'Path'}             = "";
  52.         $self->{'Arguments'}        = "";
  53.         $self->{'WorkingDirectory'} = "";
  54.         $self->{'Description'}      = "";
  55.         $self->{'ShowCmd'}          = 0;
  56.         $self->{'Hotkey'}           = 0;
  57.         $self->{'IconLocation'}     = "";
  58.         $self->{'IconNumber'}       = 0;
  59.  
  60.         $self->Load($file) if $file;
  61.         
  62.     } else {
  63.         return undef;
  64.     }
  65.     $self;
  66. }  
  67.  
  68. sub Load {
  69.     my($self, $file) = @_;
  70.     return undef unless ref($self);
  71.   
  72.     my $result = _Load($self->{'ilink'}, $self->{'ifile'}, $file);
  73.  
  74.     if(defined($result)) {
  75.   
  76.         $self->{'File'} = $file;
  77.         $self->{'Path'} = _GetPath($self->{'ilink'}, $self->{'ifile'},0);
  78.         $self->{'ShortPath'} = _GetPath($self->{'ilink'}, $self->{'ifile'},1);
  79.         $self->{'Arguments'} = _GetArguments($self->{'ilink'}, $self->{'ifile'});
  80.         $self->{'WorkingDirectory'} = _GetWorkingDirectory($self->{'ilink'}, $self->{'ifile'});
  81.         $self->{'Description'} = _GetDescription($self->{'ilink'}, $self->{'ifile'});
  82.         $self->{'ShowCmd'} = _GetShowCmd($self->{'ilink'}, $self->{'ifile'});
  83.         $self->{'Hotkey'} = _GetHotkey($self->{'ilink'}, $self->{'ifile'});
  84.         ($self->{'IconLocation'},
  85.          $self->{'IconNumber'}) = _GetIconLocation($self->{'ilink'}, $self->{'ifile'});
  86.     }
  87.     return $result;
  88. }
  89.  
  90.  
  91. sub Set {
  92.     my($self, $path, $arguments, $dir, $description, $show, $hotkey, 
  93.        $iconlocation, $iconnumber) = @_;
  94.     return undef unless ref($self);
  95.  
  96.     $self->{'Path'}             = $path;
  97.     $self->{'Arguments'}        = $arguments;
  98.     $self->{'WorkingDirectory'} = $dir;
  99.     $self->{'Description'}      = $description;
  100.     $self->{'ShowCmd'}          = $show;
  101.     $self->{'Hotkey'}           = $hotkey;
  102.     $self->{'IconLocation'}     = $iconlocation;
  103.     $self->{'IconNumber'}       = $iconnumber;
  104.     return 1;
  105. }
  106.  
  107.  
  108. sub Save {
  109.     my($self, $file) = @_;
  110.     return undef unless ref($self);
  111.  
  112.     return undef if not $file and not $self->{'File'};
  113.     $file = $self->{'File'} if not $file;
  114.  
  115.     _SetPath($self->{'ilink'}, $self->{'ifile'}, $self->{'Path'});
  116.     _SetArguments($self->{'ilink'}, $self->{'ifile'}, $self->{'Arguments'});
  117.     _SetWorkingDirectory($self->{'ilink'}, $self->{'ifile'}, $self->{'WorkingDirectory'});
  118.     _SetDescription($self->{'ilink'}, $self->{'ifile'}, $self->{'Description'});
  119.     _SetShowCmd($self->{'ilink'}, $self->{'ifile'}, $self->{'ShowCmd'});
  120.     _SetHotkey($self->{'ilink'}, $self->{'ifile'}, $self->{'Hotkey'});
  121.     _SetIconLocation($self->{'ilink'}, $self->{'ifile'},
  122.                      $self->{'IconLocation'}, $self->{'IconNumber'});
  123.  
  124.     my $result = _Save($self->{'ilink'}, $self->{'ifile'}, $file);
  125.     return $result;
  126. }
  127.  
  128. sub Resolve {
  129.     my($self, $flags) = @_;
  130.     return undef unless ref($self);
  131.     $flags = 1 unless defined($flags);
  132.     my $result = _Resolve($self->{'ilink'}, $self->{'ifile'}, $flags);
  133.     return $result;
  134. }
  135.  
  136.  
  137. sub Close {
  138.     my($self) = @_;
  139.     return undef unless ref($self);
  140.  
  141.     my $result = _Release($self->{'ilink'}, $self->{'ifile'});
  142.     $self->{'released'} = 1;
  143.     return $result;
  144. }
  145.  
  146. sub Path {
  147.     my($self, $value) = @_;
  148.     return undef unless ref($self);
  149.  
  150.     if(not defined($value)) {
  151.         return $self->{'Path'};
  152.     } else {
  153.         $self->{'Path'} = $value;
  154.     }
  155.     return $self->{'Path'};
  156. }
  157.  
  158. sub ShortPath {
  159.     my($self) = @_;
  160.     return undef unless ref($self);
  161.     return $self->{'ShortPath'};
  162. }
  163.  
  164. sub Arguments {
  165.     my($self, $value) = @_;
  166.     return undef unless ref($self);
  167.  
  168.     if(not defined($value)) {
  169.         return $self->{'Arguments'};
  170.     } else {
  171.         $self->{'Arguments'} = $value;
  172.     }
  173.     return $self->{'Arguments'};
  174. }
  175.  
  176. sub WorkingDirectory {
  177.     my($self, $value) = @_;
  178.     return undef unless ref($self);
  179.  
  180.     if(not defined($value)) {
  181.         return $self->{'WorkingDirectory'};
  182.     } else {
  183.         $self->{'WorkingDirectory'} = $value;
  184.     }
  185.     return $self->{'WorkingDirectory'};
  186. }
  187.  
  188.  
  189. sub Description {
  190.     my($self, $value) = @_;
  191.     return undef unless ref($self);
  192.  
  193.     if(not defined($value)) {
  194.         return $self->{'Description'};
  195.     } else {
  196.         $self->{'Description'} = $value;
  197.     }
  198.     return $self->{'Description'};
  199. }
  200.  
  201. sub ShowCmd {
  202.     my($self, $value) = @_;
  203.     return undef unless ref($self);
  204.  
  205.     if(not defined($value)) {
  206.         return $self->{'ShowCmd'};
  207.     } else {
  208.         $self->{'ShowCmd'} = $value;
  209.     }
  210.     return $self->{'ShowCmd'};
  211. }
  212.  
  213. sub Hotkey {
  214.     my($self, $value) = @_;
  215.     return undef unless ref($self);
  216.  
  217.     if(not defined($value)) {
  218.         return $self->{'Hotkey'};
  219.     } else {
  220.         $self->{'Hotkey'} = $value;
  221.     }
  222.     return $self->{'Hotkey'};
  223. }
  224.  
  225. sub IconLocation {
  226.     my($self, $value) = @_;
  227.     return undef unless ref($self);
  228.  
  229.     if(not defined($value)) {
  230.         return $self->{'IconLocation'};
  231.     } else {
  232.         $self->{'IconLocation'} = $value;
  233.     }
  234.     return $self->{'IconLocation'};
  235. }
  236.  
  237. sub IconNumber {
  238.     my($self, $value) = @_;
  239.     return undef unless ref($self);
  240.  
  241.     if(not defined($value)) {
  242.         return $self->{'IconNumber'};
  243.     } else {
  244.         $self->{'IconNumber'} = $value;
  245.     }
  246.     return $self->{'IconNumber'};
  247. }
  248.  
  249. sub Version {
  250.     return $VERSION;
  251. }
  252.  
  253.  
  254.  
  255. sub DESTROY {
  256.     my($self) = @_;
  257.  
  258.     if(not $self->{'released'}) {
  259.         _Release($self->{'ilink'}, $self->{'ifile'});
  260.     }
  261. }
  262.  
  263. sub END { 
  264.     _Exit(); 
  265. }
  266.  
  267.  
  268. bootstrap Win32::Shortcut;
  269.  
  270.  
  271.  
  272. 1;
  273. __END__
  274.  
  275.